"""This is a test Python program.
Written by ALSweigart al@inventwithpython.com

This program was designed for Python 3, not Python 2.
"""

def spam():
    """This is amultiliine comment to help
    explain what the spam() function does."""
    print('Hello!')

spam="That is Alice's cat."

print(spam)
print(spam[0:5]) 

print(spam+" wo de") #字符串连接

print('That' in spam)
print(spam.upper()) #转大写
print(spam.lower()) #转小写
print(spam.isupper()) 
print(spam.islower())

x=','.join(['1','2','3']) #字符串连接
print(x) 

print(spam.split(' '))

print(r'That is Carol\'s cat.')

print('''Dear Alice,

Eve's cat has benn arrested for catnapping, cat burglarg, and extortion.

Sincerely,,
Bob''')


def printPicnic(itemsDict, leftWidth, rightWidth):
    print('PICNIC ITEMS'.center(leftWidth + rightWidth, '-'))
    for k, v in itemsDict.items():
        print(k.ljust(leftWidth,'.') + str(v).rjust(rightWidth))


picnicItems = {'snadwiches':4,'apples':12,'cups':4,'cookies':8000}
printPicnic(picnicItems,12,5)
printPicnic(picnicItems,20,6)
printPicnic(picnicItems, 14, 8)

